/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved. 
 */
package com.icinfo.cloud.provider.punish.config.controller;

import com.icinfo.cloud.provider.punish.config.dto.ConfigAllRoleInfoRequest;
import com.icinfo.cloud.provider.punish.config.dto.ConfigDefaultApprovalPersonRequest;
import com.icinfo.cloud.provider.punish.config.dto.ConfigDefaultApprovalPersonSaveDto;
import com.icinfo.cloud.provider.punish.config.dto.ConfigDefaultUserInfoRequest;
import com.icinfo.cloud.provider.punish.config.model.ConfigDefaultApprovalPerson;
import com.icinfo.cloud.provider.punish.config.service.IConfigDefaultApprovalPersonService;
import com.icinfo.cloud.provider.punish.config.vo.ConfigAllRoleInfoVo;
import com.icinfo.cloud.provider.punish.config.vo.ConfigDefaultApprovalPersonVo;
import com.icinfo.cloud.provider.punish.config.vo.ConfigDefaultUserInfoVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 描述:  config_default_approval_person 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年12月05日
 */
@RestController
@RequestMapping("/punish/config/configDefaultApprovalPerson")
public class ConfigDefaultApprovalPersonController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(ConfigDefaultApprovalPersonController.class);

    @Autowired
    private IConfigDefaultApprovalPersonService configDefaultApprovalPersonService;
     /**
      * 默认审批人列表
      * @author liyafeng
      * @date 2022/12/7
       * @param request
      * @return {@link Result< List< ConfigDefaultApprovalPerson>>}
      */
    @PostMapping("/getlist")
    public Result<List<ConfigDefaultApprovalPersonVo>> list(@RequestBody @Validated ConfigDefaultApprovalPersonRequest request) {
        List<ConfigDefaultApprovalPersonVo> configDefaultApprovalPersons=configDefaultApprovalPersonService.getConfigDefaultApprovalPersonList(request);
        return Result.success("获取成功",configDefaultApprovalPersons);
    }
    /**
     * 默认审批人保存
     * @author liyafeng
     * @date 2022/12/8
      * @param saveDto
     * @return {@link Result< String>}
     */
    @PostMapping("/save")
    public Result<String> save(@RequestBody @Validated ConfigDefaultApprovalPersonSaveDto saveDto) {
        int  num=configDefaultApprovalPersonService.saveConfigDefaultApprovalPerson(saveDto);
        if(num>0){
            return Result.success("配置成功");
        }
        return Result.error("配置失败");
    }
    /**
     * 根据角色获取人员信息
     * @author liyafeng
     * @date 2022/12/8
      * @param request
     * @return {@link Result< List< ConfigDefaultUserInfoVo>>}
     */
    @PostMapping("/getConfigDefaultUserInfoVo")
    public Result<ConfigDefaultUserInfoVo> list(@RequestBody @Validated ConfigDefaultUserInfoRequest request) {
        ConfigDefaultUserInfoVo vo=configDefaultApprovalPersonService.getConfigDefaultApprovalPersonVo(request);
        return Result.success("获取成功",vo);
    }
    /**
     * 根据单位编码获取所有审批角色
     * @author liyafeng
     * @date 2022/12/11
      * @param request
     * @return {@link Result< ConfigAllRoleInfoVo>}
     */
    @PostMapping("/getAllRoleInfo")
    public Result<ConfigAllRoleInfoVo> getAllRoleInfo(@RequestBody @Validated ConfigAllRoleInfoRequest request) {
        ConfigAllRoleInfoVo vo=configDefaultApprovalPersonService.getAllRoleInfo(request);
        return Result.success("获取成功",vo);
    }






}